a = 'hello world'
b = "abcdefg"
print(type(a))
print(type(b))

name1 = 'Tom'
name2 = "Rose"
name3 = ''' Tom '''
name4 = """ Rose """
a = ''' i am Tom,
        nice to meet you! '''
b = """ i am Rose,
        nice to meet you! """

c = "I'm Tom"
d = 'I\'m Tom'

print('hello world')
name = 'Tom'
print('我的名字是%s' % name)
print(f'我的名字是{name}')

name = input('请输入您的名字：')
print(f'您输入的名字是{name}')
print(type(name))
password = input('请输入您的密码：')
print(f'您输入的密码是{password}')
print(type(password))

name = "abcdef"
print(name[1])
print(name[0])
print(name[2])

name = "abcdefg"
print(name[2:5:1]) # cde
print(name[2:5])
print(name[:5])
print(name[1:])
# cde
# abcde
# bcdefg
print(name[:]) # abcdefg
print(name[::2]) # aceg
print(name[:-1]) # abcdef, 负1表示倒数第一个数据
print(name[-4:-1]) # def
print(name[::-1]) # gfedcba

mystr = "hello world and itcast and itheima and Python"
print(mystr.find('and')) # 12
print(mystr.find('and', 15, 30)) # 23
print(mystr.find('ands')) # -1

mystr = "hello world and itcast and itheima and Python"
print(mystr.index('and')) # 12
print(mystr.index('and', 15, 30)) # 23
print(mystr.index('ands')) # 报错

mystr = "hello world and itcast and itheima and Python"
print(mystr.count('and')) # 3
print(mystr.count('ands')) # 0
print(mystr.count('and', 0, 20)) # 1

mystr = "hello world and itcast and itheima and Python"
# 结果：hello world he itcast he itheima he Python
print(mystr.replace('and', 'he'))
# 结果：hello world he itcast he itheima he Python
print(mystr.replace('and', 'he', 10))
# 结果：hello world and itcast and itheima and Python
print(mystr)

mystr = "hello world and itcast and itheima and Python"
# 结果：['hello world ', ' itcast ', ' itheima ', ' Python']
print(mystr.split('and'))
# 结果：['hello world ', ' itcast ', ' itheima and Python']
print(mystr.split('and', 2))
# 结果：['hello', 'world', 'and', 'itcast', 'and', 'itheima', 'and', 'Python']
print(mystr.split(' '))
# 结果：['hello', 'world', 'and itcast and itheima and Python']
print(mystr.split(' ', 2))

list1 = ['chuan', 'zhi', 'bo', 'ke']
t1 = ('aa', 'b', 'cc', 'ddd')
# 结果：chuan_zhi_bo_ke
print('_'.join(list1))
# 结果：aa...b...cc...ddd
print('...'.join(t1))

mystr = "hello world and itcast and itheima and Python"
# 结果：Hello world and itcast and itheima and python
print(mystr.capitalize())

mystr = "hello world and itcast and itheima and Python"
# 结果：Hello World And Itcast And Itheima And Python
print(mystr.title())

mystr = "hello world and itcast and itheima and Python"
# 结果：hello world and itcast and itheima and python
print(mystr.lower())

mystr = "hello world and itcast and itheima and Python"
# 结果：HELLO WORLD AND ITCAST AND ITHEIMA AND PYTHON
print(mystr.upper())

mystr = "hello world and itcast and itheima and Python "
# 结果：True
print(mystr.startswith('hello'))
# 结果False
print(mystr.startswith('hello', 5, 20))

mystr = "hello world and itcast and itheima and Python"
# 结果：True
print(mystr.endswith('Python'))
# 结果：False
print(mystr.endswith('python'))
# 结果：False
print(mystr.endswith('Python', 2, 20))

mystr1 = 'hello'
mystr2 = 'hello12345'
# 结果：True
print(mystr1.isalpha())
# 结果：False
print(mystr2.isalpha())

mystr1 = 'aaa12345'
mystr2 = '12345'
# 结果： False
print(mystr1.isdigit())
# 结果：False
print(mystr2.isdigit())

mystr1 = 'aaa12345'
mystr2 = '12345-'
# 结果：True
print(mystr1.isalnum())
# 结果：False
print(mystr2.isalnum())

mystr1 = '1 2 3 4 5'
mystr2 = '     '
# 结果：False
print(mystr1.isspace())
# 结果：True
print(mystr2.isspace())